package com.njwb.day08.system.service.impl;

import com.njwb.day08.system.dao.StudentDao;
import com.njwb.day08.system.dao.impl.StudentDaoImpl;
import com.njwb.day08.system.entity.Student;
import com.njwb.day08.system.service.StudentService;

public class StudentServiceImpl implements StudentService {
    @Override
    public Student[] findAll() {
        StudentDao studentDao=new StudentDaoImpl();
        return studentDao.selectAll();
    }

    @Override
    public int findByNo(int no) {
        StudentDao studentDao=new StudentDaoImpl();
        int index=studentDao.selectByNo(no);
        return index;
    }

    @Override
    public String addStudent(Student student) {
        StudentDao studentDao=new StudentDaoImpl();
        studentDao.insert(student);
        return "学生信息添加成功...";
    }

    @Override
    public String modifyStudent(Student student,int index) {
        StudentDao studentDao=new StudentDaoImpl();
        studentDao.updateStudent(student,index);
        return "修改成功";
    }

    @Override
    public String removeStudent(int index) {
        StudentDao studentDao=new StudentDaoImpl();
        studentDao.deleteStudent(index);
        return "删除成功";
    }

    @Override
    public Student findByNameOrNo(String name,int no) {
        StudentDao studentDao=new StudentDaoImpl();
        return studentDao.selectByNameOrNo(name,no);
    }

    @Override
    public Student[] findStudentAsc() {
        StudentDao studentDao=new StudentDaoImpl();
        return studentDao.selectStudentAsc();
    }
}
